﻿@{
    var Culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;    
}
@helper SelectedItem(string c, string culture)
{
    if (c == culture)
    {
        @:selected="selected"
    }
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    @if (ViewBag.RightToLeft)
    {
        <link href="@Url.Content("~/Content/textdirecction.css")"  rel="Stylesheet" type="text/css" />
    }
    <meta http-equiv="Content-Language" content="@Culture" /> 
</head>
<body>
    <div class="page">
        <div id="header">
            <div id="title">
                <h1>@Internationalization.Resources.SystemTitle</h1>
            </div>
            <div id="logindisplay">
                @Html.Partial("_LogOnPartial")
            </div>
            <div id="language">
                <div class="language-text">@Internationalization.Resources.Language</div>
                @using (Html.BeginForm("Set", "SetCulture")) 
                {
                    Culture = Culture.ToLower();
                    <select id="CultureList" name="CultureList">
                        <option value="ar-sa" @SelectedItem("ar-sa", Culture)>Arabic</option>
                        <option value="zh-cn" @SelectedItem("zh-cn", Culture)>Chinese</option>
                        <option value="en-us" @SelectedItem("en-us", Culture)>English</option>
                        <option value="fr-fr" @SelectedItem("fr-fr", Culture)>French</option>
                        <option value="de-de" @SelectedItem("de-de", Culture)>German</option>
                        <option value="he" @SelectedItem("he-il", Culture)>Hebrew</option>
                        <option value="ru-ru" @SelectedItem("ru-ru", Culture)>Russian</option>
                        <option value="es-es" @SelectedItem("es-es", Culture)>Spanish</option>
                    </select>
                    
                    string url = ViewContext.RouteData.Values["controller"].ToString() + "," + ViewContext.RouteData.Values["action"].ToString();
                    HttpCookie cookie = Request.Cookies["_url"];
                    if (cookie != null)
                    {
                        cookie.Value = url;
                    }
                    else
                    {
                        cookie = new HttpCookie("_url");
                        cookie.HttpOnly = false; // Not accessible by JS.
                        cookie.Value = url;
                        cookie.Expires = DateTime.Now.AddYears(1);
                    }
                    Response.Cookies.Add(cookie);
                }

                <script type="text/javascript">
                    $("#CultureList").change(function () {
                        $(this).parents("form").submit();
                    });
                </script>
                <div class="language-clear"></div>
            </div>
            <div id="menucontainer">
                <ul id="menu">
                    <li>@if (Session["UserLogin"] != null)
                        {
                            var UserInfo = (DAL.UserInfo)Session["UserLogin"];
                            if (UserInfo.Type == 0)
                            {
                                 @Html.ActionLink(Internationalization.Resources.Index, "EmployerIndex", "Home");
                            }
                            else
                            {
                                 @Html.ActionLink(Internationalization.Resources.Index, "WorkerIndex", "Home");
                            }
                        }
                        else
                        {
                            @Html.ActionLink(Internationalization.Resources.Index, "Login", "Account");
                        }
                    </li>
                    <li>@Html.ActionLink(Internationalization.Resources.About, "About", "Account")</li>
                </ul>
            </div>
        </div>
        <div id="main">
            @RenderBody()
        </div>
        <div id="footer">
        </div>
    </div>
</body>
</html>
